#pragma once
#include "fxcc/core/graph/opengl3/font/Character.h"
#include "fxcc/core/graph/common/TextLine.h"

namespace fxcc
{
    namespace graph
    {
        namespace opengl3
        {
            namespace font
            {
                struct FXCC_API  FontLib
                {

                    std::string m_Path;

                    FT_Library m_Lib;
                    FT_Face m_Face;
                    std::string m_Family;

                    fxcc::graph::common::GeometryData m_FontGeoData;

                    std::shared_ptr<fxcc::graph::opengl3::MeshJack> m_FontMesh;

                    bool m_Available{ false };

                    FontLib(const std::string &path);
     
                    std::map<Character::Desc, std::shared_ptr<fxcc::graph::opengl3::font::Character>> m_CharMap;

                    bool Create();

                    void DoneFace();

                    void DoneFreetype();

                    void Done();

                    bool HasWChar(const wchar_t &c, int fontSize);

                    bool InitResources();

                    bool LoadWChar(const wchar_t& c, int fontSize);

                    bool RenderWChar(const wchar_t& c, int fontSize,  glm::vec2& startPos);

                    bool LoadWstring(const std::wstring &str, int fontSize);

                    using TextLine = fxcc::graph::common::TextLine;

                    void RenderTextMesh(const TextLine & textLine);

                    ~FontLib();

                    static std::wstring UTF8ToWString(const std::string &utf8Str)
                    {
                        std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
                        return converter.from_bytes(utf8Str);
                    }

                private:
                    // 3D Render Text
                };
            };
        };
    }
}